<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
	<head>
		<title>井冈山智慧社区-民意征集</title>
		<%@ include file="../../common/Website-list.jsp"%>
		<link href="//netdna.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet" />
                        
		<link rel="stylesheet" type="text/css" href="<%=bpath%>Scripts/metisMenu/metisMenu.css"/>
		<link rel="stylesheet" type="text/css" href="<%=bpath%>Scripts/metisMenu/metisFolder.css"/>		
		<script type="text/javascript" src="<%=bpath%>Scripts/metisMenu/metisMenu.js"></script>				
		<script type="text/javascript" src="<%=bpath%>Scripts/jquery/jquery.form.js"></script>		
		<script type="text/javascript" src="<%=bpath%>Scripts/jquery/jquery.validate.min.js"></script>	
		<link rel="stylesheet" type="text/css" href="<%=bpath%>pages/WebSitePc/css/categoryMenu.css"/>		
		
			
		<link rel="stylesheet" type="text/css" href="<%=bpath%>pages/WebSitePc/css/asynPage.css"/>	
				
		<script type="text/javascript" src="<%=bpath%>pages/WebSitePc/js/json2.js"></script>
		<script type="text/javascript" src="<%=bpath%>pages/WebSitePc/js/asynPage.js"></script>
				
				
		<script type="text/javascript" src="<%=bpath%>pages/WebSitePc/js/adviceAdd.js"></script>
		<script type="text/javascript">
			
			$(function(){
				
				if('${data.siteMenuList}'!=null && ${data.siteMenuList.size()}>0){
					//获取第一个,顶部 
					var firstId='${data.siteMenuList.get(0).id}';
					var firstName='${data.siteMenuList.get(0).menuName}';
					var url='${data.siteMenuList.get(0).url}';					
					$olda='#nav'+firstId; //选中导航					
					
					var lastId='${data.siteMenuList.get(data.siteMenuList.size()-1).id}';
					
					getMenuLeft(firstId,firstName,url,lastId);							
				}	
				
				// 还未到征集时间
				var startDate=('${data.solicitPublic.startDate}'==null? "" :new Date('${data.solicitPublic.startDate}').format("yyyy-MM-dd"));
				var endDate=('${data.solicitPublic.endDate}'==null? "" :new Date('${data.solicitPublic.endDate}').format("yyyy-MM-dd"));
				var nowDate=new Date().format("yyyy-MM-dd");
				if(startDate>nowDate){
					$(".pinlun").css("display","none");			
					$("#zanSpan").attr("onclick", "null"); 
				}else if(endDate<=nowDate){
					$(".pinlun").css("display","none");
					$("#zanSpan").attr("onclick", "null"); 
				}
				
				//提交评论
				$("#tableForm").validate({							
					rules: {
						contents:{
							required:true,							
							byteRangeLength:[10,1000]
						}						
					},
					messages: {		
						contents:{
							required:"<font color=red><br/>请输入内容</font>",							
							byteRangeLength:"<font color=red><br/>内容在5到1000之间字</font>"
						}						
					},							
				 	submitHandler: function (form) {
				 		var url = $ctx+"/SiteIndex/SolicitCommentAdd.json";
				 		$(form).ajaxSubmit({
								type:"post",
							    url:url,		
							    data:{  							    	  		    	  
							    	  typeId:1  //评论
							    },  	
								contentType:"application/x-www-form-urlencoded;charset=UTF-8",
								error:function(){},
								success:function(data){
									if(data!=null){
										if(data.success){											
											alert("评论已提交,感谢您的参与！");
											$("#contents").val("");
											//更新评论 
											getCommentsByPage();
										}else{
											alert("保存失败,"+data.error);
										}
									}				
									
								}
						 });
			        }
				});
				
				
				getCommentsByPage();
				
				
			});
			
			//查找咨询留言--有分页
			function getCommentsByPage(){
				var params = "typeId=1&fk_spid="+$("#fk_spid").val();							
				var pageUrl=$ctx+'/SiteIndex/querySolicitCommentPage.json';					
				$("#paging").asynPage(pageUrl,params,"#articlePage",buildComments,5,"rows","total");				
			}
			
			//异步分页--创建评论列表
			function buildComments(data){				
				if(data!=null && data.length>0){		    		
					var articleList='<table width="100%" cellspacing="0" cellpadding="0" border="0" align="center"> <tbody>';										
					$.each(data,function(idx,obj){
						var addhtml = '<tr><td width="56" valign="top">网民'+(obj.id)+'</td>'+
										  '<td style="text-align:left;">'+obj.contents+'</td>'+	
									  '</tr><tr><td></td>'+	  
										  '<td style="text-align:right;">提交时间：'+(obj.createTime==null? "" :new Date(obj.createTime).format("yyyy-MM-dd hh:mm:ss"))+'</td>'+	
								      '</tr>';
						articleList+=addhtml;	    
					});		    		
					articleList+='</tbody></table>';		
					$("#articlePage").append(articleList);					
				}else{
					$("#articlePage").append('没有符合条件的数据!');
				}			
			}
			
			//点赞
			function toZan(fkspid){				
				$.ajax({  
					type: "POST",  
			        url: $ctx+'SiteIndex/SolicitCommentAdd.json',			       
				    data:{  
				    	  fk_spid:fkspid,				    	  
				    	  typeId:0 //点赞
				    },  	
				    dataType:'json',  
				    success:function(data) { 
				    	if(data!=null){				    		
				    		if(data.success){
				    			alert("点赞成功！感谢您的参与！");															
							}else{
								alert(data.error);
							}							    	
				    		$("#zanNum").text(data.joinNum);
				    	}	
				    },  
				     error : function() {  
				          alert("异常！");  
				     }  
				});
				
				
				
			}
			
			
			
			
			
			
		</script>
	</head>
<body>
	<!--Header Holder-->
	<jsp:include page="../../WebSitePc/heads.jsp" />	
	<!--main start-->	
	<div class="main">
		<div class="cate01">
			<div class="crumbs">			
				您现在位置：<a href="<%=basePath%>" target="_self">首页</a> &gt;				
                <c:if test= "${data.siteMenuList.size()>0}" >
                    <c:forEach items= "${data.siteMenuList}" var ="tf" varStatus = "st">
                         <c:if test="${!st.last}">     						
     						<a href = "<%=basePath%>${tf.url}" target = "_self" class= "" >${tf.menuName} </a > &gt;
     					</c:if>       
     					<c:if test="${st.last}">
     						<a href = "<%=basePath%>${tf.url}" target = "_self" class= "" >
     						<font color="#2c95b7">${tf.menuName}</font></a >
     					</c:if>  
                    </c:forEach >
                </c:if >         
			</div>
			<div class="cebox">
      			<div class="boxLeft">
      				<aside class="sidebar">
			      		<nav class="sidebar-nav">
			        		<ul id="menuLeft" class="metismenu">
			        			<!-- 左侧 树 菜单  -->
			        		</ul>
			      		</nav>
			    	</aside>
				</div>				
				
				<!-- 右侧  民意征集 详情页面-->		
				<div class="boxRight">				
			    	<div class="solicitInfoView">	
			    		<!-- 正文-->		      		
			      		<h2 class="detailsh2"> ${data.solicitPublic.title}</h2>
			      		<p align="center">
			      			征集意见时间段：
			      		 	<fmt:formatDate pattern="yyyy年MM月dd日"  value="${data.solicitPublic.startDate}"  type="both" />
			      		 	--
			      		 	<fmt:formatDate pattern="yyyy年MM月dd日"  value="${data.solicitPublic.endDate}"  type="both" />			      		
			      		</p>
			      		 <div style="margin:30px 0px;">
			      		 	 ${data.solicitPublic.contents}			      		 
			      		 </div>	 	
			      		 
			      		 <!-- 点赞-->			      		 
			      		 <div style="text-align:right;">	
			      		 	<span id="zanSpan" onclick="toZan(${data.solicitPublic.id});" class="fa fa-thumbs-o-up fa-3x" style="color: #e44c2c;cursor:pointer;"></span>
			      		 	(已有<lable id="zanNum">${data.solicitPublic.totality}</lable>个赞)
			      		 </div>			
			      		       
			      		 <!-- 提交评论-->
			      		 <form id="tableForm" name="curForm" method="post" action="<%=basePath%>/SiteIndex/SolicitCommentAdd.json">		
			      		 <div class="pinlun">
			      		 	<h3 class="zhengjidetailsh3">
			      		 		<span class="fa fa-commenting-o fa-2x" style="color: #0c6cb8;"></span>
			      		 		 评论内容：
			      		 	</h3>
			      		 	<div class="zhengjidetailsnr">
			      		 		<input  name="fk_spid" id="fk_spid" value="${data.solicitPublic.id}" type="hidden" />
			      		 		<input  name="is_publish" id="is_publish" value="1" type="hidden" />
								<textarea id="contents" name="contents" class="zhengjidetailstextarea" rows="5" cols="100"></textarea>
							</div>
							<div class="zhengjidetailsbtn">								
								<input type="submit" value="提&nbsp;&nbsp;交" class="mailbtn" />
							</div>
			      		 </div>	
    					 </form>
			      		 <div class="clear"></div>
			    	</div>	
			    	
			    	<!-- 回复 -->
			    	<div class="solicitInfoView">				    		 
			      		 <!-- 网友意见列表 -->
			      		 <div class="solicitinfo">
						      <div class="mailbt">网友意见列表</div>
						      <div class="mailinfocon" id="articlePage" style="margin-bottom:20px;">  
						      </div>
						      <div id="paging" class="page"></div>
						      
						      <div class="clear"></div>
						  </div>	
						 <!-- 意见采纳说明 -->
						  <c:if test= "${data.solicitPublic.adopteds!=null}" >
							  <div class="solicitinfo">
							      <div class="mailbt">意见采纳说明</div>
							      <div class="mailinfocon">
							      		${data.solicitPublic.adopteds}						     
							      </div>
							  </div>      
						  </c:if>
						  <div class="clear"></div>	  
			    	</div>  			    	
			    	    				
    				<div style="margin-top:10px;text-align:center;">
    					<input class="mailbtn2" type="button" onclick="window.history.go(-1)" value="返回列表" />
    				</div>
    				
				</div>				
			</div>			
		</div>	
	</div>
	
	
	<script type="text/javascript">
		//通过 导航  生成菜单	
		$(function () {    		
			$('#menuLeft').metisMenu({doubleTapToGo: true });
		});
	</script>
	
	<!--foot start-->
	<jsp:include page="../../WebSitePc/footer.jsp" />	
</body>
</html>